const { cleanEnv, str, num, bool } = require("envalid");
const dotenv = require("dotenv").config();

const env = cleanEnv(process.env, {
    PORT: num({ default: 5000 }),
    ENV: str({
        choices: ["development", "production"],
        default: "development"
    }),
    DB_URL: str(),
    UPLOAD_URL: str(),
    CORS: str(),
    SESSION_SECRET: str({ default: "cowen is the best" })
});

module.exports = {
    PORT: env.PORT, // 服务端口
    ENV: env.ENV, // 环境变量
    CORS: env.CORS, // 跨域配置
    DB_URL: env.DB_URL, // 数据库连接地址
    UPLOAD_URL: env.UPLOAD_URL, // 文件上传地址
    SESSION_SECRET: env.SESSION_SECRET // session密钥
};
